Class Problem

java.lang.Object
edu.uky.ai.csp.kr.Problem
Direct Known Subclasses:
MapColoring, Sudoku

public class Problem
extends java.lang.Object
A constraint satisfaction problem is composed of variables (each with a set of potential values called a domain) and constraints on the values those variable can be assigned.
Author:
Stephen G. Ware
  • Field Summary

    Fields 
    Modifier and Type Field Description
    java.lang.Iterable<Constraint> constraints
    A set of all the constraints that a solution to this problem must meet
    java.lang.Iterable<Variable> variables
    A set of all the variables defined for this problem
  • Constructor Summary

    Constructors 
    Constructor Description
    Problem()  
  • Method Summary

    Modifier and Type Method Description
    void addConstraint​(Constraint constraint)
    Adds a new constraint to the problem.
    void addVariable​(Variable variable, Domain domain)
    Defines a new variable, along with all the possible values it can be assigned, for this problem.
    Domain getDomain​(Variable variable)
    Returns the set of possible values that a given variable can be assigned in the initial state of this problem.
    java.lang.String toString​(Solution solution)
    Returns a problem-specific string representation of a potential solution.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • variables

      public final java.lang.Iterable<Variable> variables
      A set of all the variables defined for this problem
    • constraints

      public final java.lang.Iterable<Constraint> constraints
      A set of all the constraints that a solution to this problem must meet
  • Constructor Details

  • Method Details

    • addVariable

      public void addVariable​(Variable variable, Domain domain)
      Defines a new variable, along with all the possible values it can be assigned, for this problem.
      Parameters:
      variable - the new variable to be defined
      domain - the possible values that variable can be assigned
    • getDomain

      public Domain getDomain​(Variable variable)
      Returns the set of possible values that a given variable can be assigned in the initial state of this problem.
      Parameters:
      variable - the variable
      Returns:
      the domain of that varaible in the initial state of the problem
    • addConstraint

      public void addConstraint​(Constraint constraint)
      Adds a new constraint to the problem.
      Parameters:
      constraint - the constraint
    • toString

      public java.lang.String toString​(Solution solution)
      Returns a problem-specific string representation of a potential solution.
      Parameters:
      solution - the solution to be rendered as a string
      Returns:
      a string